import Vue from 'vue'
import VueRouter from 'vue-router'
Vue.use(VueRouter)

import Login from 'views/Login/Login.vue'
import Home from 'views/Login/Home.vue'
import Welcome from 'views/Login/Welcome.vue'
import User from 'views/User/User.vue'
import Notice from 'views/Notice/Notice.vue'
import Room from 'views/Room/Room.vue'
import Seatlog from 'views/Seat/Seatlog.vue'

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes: [
    { path: '/', redirect: '/login' },  
    { path: '/login', component: Login },
    { path: '/home', component: Home, redirect: "/welcome",
      children:[
      { path: '/welcome', component: Welcome},
      { path: '/user', component: User},
      { path: '/notice', component: Notice},
      { path: '/room', component: Room},
      { path: '/seatlog', component: Seatlog},
    ]},
  ]
})

//导航守卫
//正式使用时打开
// router.beforeEach((to, from, next) => {
//   if (to.path === "/login") return next();
//   //验证TOKEN
//   const tokenStr = window.sessionStorage.getItem("token");
//   if (!tokenStr) {
//     Vue.prototype.$message.warning("请先登录再进行此操作！");
//     window.sessionStorage.clear();
//     return next("/login");
//   }
//   next();
// });

export default router
 